package com.kefu.chat.vo;

import com.kefu.chat.model.ChatConversation;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractInsertVo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @author CodeGenerator
 * @date 2022/08/15
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "内部会话")
public class ChatConversationInsertVo extends AbstractInsertVo<ChatConversation> {


    @ApiModelProperty(value = "会话类型，0单聊，1群聊")
    private Integer type;
    @ApiModelProperty(value = "单聊的时候，为另外一个坐席的id；群聊的时候为其他坐席的id，逗号分隔")
    private String users;
    @ApiModelProperty(value = "会话名称，群聊的时候需要传递会话名称，单聊不用传")
    private String name;

    @Override
    public ChatConversation convert() {
        ChatConversation info = new ChatConversation();
        info.setType(type);
        info.setName(name);
        info.setUsers(users);
        KefuContext context = KefuContext.getKefuContext();
        info.setTenantId(context.getTenantId());
        info.setCreateUser(context.getUserId());
        info.setCreateTime(context.getNow());
        info.setLastMsgTime(context.getNow());
        return info;
    }
}